<html>
<!--
Copyright 2004 ThoughtWorks, Inc

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<head>
    <meta content="text/html; charset=ISO-8859-1"
          http-equiv="content-type">
    <title>Select a Test Suite</title>
    <script language="JavaScript" type="text/javascript" src="scripts/selenium-browserdetect.js"></script>
    <script language="JavaScript" type="text/javascript" src="scripts/xmlextras.js"></script>
    <script>

        function load() {
            if (browserVersion.isHTA) {
                document.getElementById("save-div").style.display = "inline";
            }
            if (/thisIsSeleniumServer/.test(window.location.search)) {
                document.getElementById("slowResources-div").style.display = "inline";
                if (browserVersion.isHTA || browserVersion.isChrome) {
                    document.getElementById("test").value = "http://localhost:4444/selenium-server/tests/TestSuite.html";
                }
            }
        }

        function autoCheck() {
            var auto = document.getElementById("auto");
            var autoDiv = document.getElementById("auto-div");
            if (auto.checked) {
                autoDiv.style.display = "inline";
            } else {
                autoDiv.style.display = "none";
            }
        }

        function slowCheck() {
            var slowResourcesCheckbox = document.getElementById("slowResources");
            var slowResources = slowResourcesCheckbox.checked ? true : false;
            var xhr = XmlHttp.create();
            var driverUrl = "http://localhost:4444/selenium-server/driver/?cmd=slowResources&1=" + slowResources;
            xhr.open("GET", driverUrl, true);
            xhr.send(null);
        }

        function saveCheck() {
            var results = document.getElementById("results");
            var check = document.getElementById("save").checked;
            if (check) {
                results.firstChild.nodeValue = "Results file ";
                document.getElementById("resultsUrl").value = "results.html";
            } else {
                results.firstChild.nodeValue = "Results URL ";
                document.getElementById("resultsUrl").value = "../postResults";
            }
        }

        function go() {
            if (!browserVersion.isHTA && !browserVersion.isChrome) return true;
            var inputs = document.getElementsByTagName("input");
            var queryString = "";
            for (var i = 0; i < inputs.length; i++) {
                var elem = inputs[i];
                var name = elem.name;
                var value = elem.value;
                if (elem.type == "checkbox") {
                    value = elem.checked;
                }
                queryString += escape(name) + "=" + escape(value);
                if (i < (inputs.length - 1)) {
                    queryString += "&";
                }
            }

            window.parent.selenium = null;
            window.parent.htmlTestRunner.controlPanel.queryString = queryString;
            window.parent.htmlTestRunner.loadSuiteFrame();
            return false;
        }
    </script>
</head>

<body onload="load()" style="font-size: x-small">
<form id="prompt" target="_top" method="GET" onsubmit="return go();" action="TestRunner.html">

    <p>
        Test Suite:
        <input id="test" name="test" size="30" value="../tests/TestSuite.html"/>
    </p>

    <p align="center"><input type="submit" value="Go"/></p>

    <fieldset>
        <legend>Options</legend>

        <p>
            <input id="multiWindow" type="checkbox" name="multiWindow" onclick="autoCheck();"/> <label
                for="multiWindow">AUT in separate window</label>

        <p>

        <div id="slowResources-div" style="display: none">
            <p>
                <input id="slowResources" type="checkbox" name="slowResources" onclick="slowCheck();" /> <label for="slowResources">Slow down web server</label>
            </p>
        </div>

        <p>
            <input id="auto" type="checkbox" name="auto" onclick="autoCheck();"/> <label for="auto">Run
            automatically</label>
        </p>

        <div id="auto-div" style="display: none">
            <p>
                <input id="close" type="checkbox" name="close"/> <label for="close">Close afterwards </label>
            </p>

            <div id="save-div" style="display: none">
                <br/><label for="save">Save to file </label><input id="save" type="checkbox" name="save"
                                                                   onclick="saveCheck();"/>
            </div>

            <p id="results">
                Results URL:
                <input id="resultsUrl" name="resultsUrl" value="../postResults"/>
            </p>

        </div>
    </fieldset>


</form>
</body>
</html>